package com.oceansoft.mobile.econsole.modules.message.entity;

import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;

public class MessageContent {
    public int content_type = 0;
    public String title;
    public String message = "";
    public String extras = "";

    public MessageContent(String content) {
        this.message = content;
    }

    public MessageContent(String content, int channel_id) {
        this.message = content;
        this.content_type = channel_id;
    }

    public MessageContent() {
    }

    public MessageContent(String content, int channel_id, String extra) {
        this.message = content;
        this.content_type = channel_id;
        this.extras = extra;
    }

    public MessageContent(String title, String content, int channel_id, String extra) {
        this.title = title;
        this.message = content;
        this.content_type = channel_id;
        this.extras = extra;
    }

    public String toJson() {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(this);
        } catch (JsonGenerationException e) {
            e.printStackTrace();
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }

    public int getContent_type() {
        return content_type;
    }

    public void setContent_type(int content_type) {
        this.content_type = content_type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getExtras() {
        return extras;
    }

    public void setExtras(String extras) {
        this.extras = extras;
    }
}